package com;

import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.RequestHandler;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@EnableSwagger2
@Configuration
public class SwaggerConfig {

    @Bean
    public Docket createRestApi(){

        Predicate<RequestHandler> selector1 = RequestHandlerSelectors.basePackage("com.libraryApp.controller");
        Predicate<RequestHandler> selector2 = RequestHandlerSelectors.basePackage("com.libraryManage.controller");

        return new Docket(DocumentationType.SWAGGER_2)
                .select()
//                .apis(RequestHandlerSelectors.basePackage("com.libraryApp.controller"))
                .apis(Predicates.or(selector1,selector2))
                .paths(PathSelectors.any())
                .build().apiInfo(new ApiInfoBuilder()
                        .title("图书馆后台管理接口")
                        .description("毕业设计")
                        .version("6.6.6")
                        .build());

    }

}
